package com.link.base.base.common.model;

import com.link.core.basic.model.BasicModel;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 安全性菜单快捷设置专用实体类
 *
 * @author yangxiaolin
 * @date 2019/03/06
 */
public class MenuTree extends BasicModel {
    /**
     * 菜单id
     */
    private Long menuId;
    /**
     * 菜单名称
     */
    private String menuName;
    /**
     * 父菜单id
     */
    private Long parentMenuId;
    /**
     * 父菜单名称
     */
    private String parentMenuName;
    /**
     * 安全性菜单集合
     */
    private List<MenuTree> safetyList;
    /**
     * 已选安全性菜单集合
     */
    private List<String> safetyCheckList;
    /**
     * 是否显示标识符
     */
    private String isShow;
    /**
     * 用于前端显示-合并数量
     */
    private String showNum;
    /**
     * 修改前安全性菜单集合
     */
    private List<MenuTree> oldList;
    /**
     * 修改后安全性菜单集合
     */
    private List<MenuTree> newList;
    /**
     * 职责id
     */
    private Long DutyId;
    /**
     * 选择的安全性菜单id
     */
    private Long safetyCheckId;
    /**
     * 用于传递参数集合
     */
    private List<String> list;

    public List<String> getList() {
        return list;
    }

    public void setList(List<String> list) {
        this.list = list;
    }

    public Long getSafetyCheckId() {
        return safetyCheckId;
    }

    public void setSafetyCheckId(Long safetyCheckId) {
        this.safetyCheckId = safetyCheckId;
    }

    public Long getDutyId() {
        return DutyId;
    }

    public void setDutyId(Long dutyId) {
        DutyId = dutyId;
    }

    public Long getMenuId() {
        return menuId;
    }

    public void setMenuId(Long menuId) {
        this.menuId = menuId;
    }

    public List<MenuTree> getOldList() {
        return oldList;
    }

    public void setOldList(List<MenuTree> oldList) {
        this.oldList = oldList;
    }

    public List<MenuTree> getNewList() {
        return newList;
    }

    public void setNewList(List<MenuTree> newList) {
        this.newList = newList;
    }

    public String getIsShow() {
        return isShow;
    }

    public void setIsShow(String isShow) {
        this.isShow = isShow;
    }

    public String getShowNum() {
        return showNum;
    }

    public void setShowNum(String showNum) {
        this.showNum = showNum;
    }

    public String getMenuName() {
        return menuName;
    }

    public void setMenuName(String menuName) {
        this.menuName = menuName;
    }

    public Long getParentMenuId() {
        return parentMenuId;
    }

    public void setParentMenuId(Long parentMenuId) {
        this.parentMenuId = parentMenuId;
    }

    public String getParentMenuName() {
        return parentMenuName;
    }

    public void setParentMenuName(String parentMenuName) {
        this.parentMenuName = parentMenuName;
    }

    public List<MenuTree> getSafetyList() {
        return safetyList;
    }

    public void setSafetyList(List<MenuTree> safetyList) {
        this.safetyList = safetyList;
    }

    public List<String> getSafetyCheckList() {
        return safetyCheckList;
    }

    public void setSafetyCheckList(List<String> safetyCheckList) {
        this.safetyCheckList = safetyCheckList;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MenuTree menuTree = (MenuTree) o;
        Boolean safetyNull = safetyList == null || safetyList.size() == 0;
        Boolean menuTreeNull = menuTree.safetyList == null || menuTree.safetyList.size() == 0;
        if ( safetyNull && menuTreeNull) {
            return Objects.equals(menuId, menuTree.menuId) && Objects.equals(safetyCheckId, menuTree.safetyCheckId);
        }
        if ( safetyNull && menuTree.safetyCheckList.size() > 0) {
            return false;
        }
        if ( menuTreeNull && safetyCheckList.size() > 0) {
            return false;
        }
        if ( safetyCheckList.size() != menuTree.safetyCheckList.size()) {
            return false;
        }
        if (safetyCheckList.size() > 0 && menuTree.safetyCheckList.size() > 0) {
            List<String> compareList = new ArrayList<>(safetyCheckList);
            compareList.removeAll(menuTree.safetyCheckList);
            return Objects.equals(menuId, menuTree.menuId) && compareList.size() == 0;
        }
        return Objects.equals(menuId, menuTree.menuId)
                && Objects.equals(safetyCheckList, menuTree.safetyCheckList);
    }

    @Override
    public int hashCode() {
        return Objects.hash(menuId, safetyCheckList);
    }
}
